package com.ht.module.job.controller;

import com.ht.module.job.entity.JobLog;
import com.ht.module.job.service.JobLogService;
import com.ht.util.CommMethod;
import com.ht.util.JsonResult;
import com.ht.util.Pager;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 定时任务执行日志 前端控制器
 * </p>
 *
 * @author hejialun
 * @since 2025-08-11
 */
@RestController
@RequestMapping("/job-log")
public class JobLogController {

    
    @Autowired
    private JobLogService jobLogService;

    



	@Operation(summary ="分页查询")
    @GetMapping("/findPage")
    public JsonResult findPage(Pager<JobLog> pager, JobLog en){
        return JsonResult.success(jobLogService.page(pager));
    }



	@Operation(summary ="通过id查询")
    @GetMapping("/get-by-id/{id}")
    public JsonResult getById(@PathVariable(value = "id") String id){
        return JsonResult.success(jobLogService.getById(id));
    }

    @Operation(summary ="新增")
    @PostMapping("/add")
    public JsonResult add(@RequestBody @Valid JobLog en){
	    CommMethod.beanCreate(en);
        jobLogService.save(en);
        return JsonResult.success();
    }

    @Operation(summary ="通过id删除")
    @DeleteMapping("/delete-by-id/{id}")
    public JsonResult delete(@PathVariable(value = "id") String id){
        jobLogService.removeById(id);
        return JsonResult.success();
    }

    @Operation(summary ="修改")
    @PutMapping("/update")
    public JsonResult updateById(@RequestBody @Valid JobLog en){
	    CommMethod.beanUpdate(en);
        jobLogService.updateById(en);
        return JsonResult.success();
    }

}
